#include "Torus.h"

ConcreteElementLoader<Torus> *Torus::loader = new ConcreteElementLoader<Torus>();

Torus::Torus(TiXmlElement *elem) { // TODO IMPLEMENT EXCEPTIONS
	if( elem != NULL ) {
		if( elem->QueryFloatAttribute("inner", &inner) == TIXML_SUCCESS &&
			elem->QueryFloatAttribute("outer", &outer) == TIXML_SUCCESS &&
			elem->QueryIntAttribute("slices", &slices) == TIXML_SUCCESS &&
			elem->QueryIntAttribute("loops", &loops) == TIXML_SUCCESS ) {	
			#ifdef DEBUG
				printf("Torus read: inner = %0.1f, outer = %0.1f, slices = %d, loops = %d \n", 
					inner, outer, slices, loops);
			#endif
		}
	}
}

void Torus::displayElement() {
	glBegin(GL_POLYGON);
		glutSolidTorus(inner,
						outer,
						slices,
						loops);
	glEnd();
}